<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>计划查询 - 国省道 - 分成资金</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/Top.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/buttons.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/common.css" />
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/datagrid-detailview.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/util/jquery.cookie.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/YMLib.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/YWLib.js"></script>
    <script type="text/javascript">
        var pageSize_ = 10;
        $(function () {
            loadDist1("xzqh",$.cookie("dist"));
            loadBmbm3('xmnf','项目年份',new Date().getFullYear());
            loadShareJhxdwh("jhxdwh", "share_funds");

            if ($.cookie('unit2').length==7) {
                $("#mybuttion2").show();
                $("#mybuttion3").show();
                $("#mybuttion4").show();
            } else {
                $("#mybuttion2").hide();
                $("#mybuttion3").hide();
                $("#mybuttion4").hide();
            }
            queryXmlist();
        });

        function zjdwtj() {
            // page/jhcx/gs/sharefunds_tj.jsp
            openWindow("添加","/jxcsxm/page/jhcx/gs/sharefunds_tj.jsp",650,350);
        }

        // todo 导出模板
        function dcmb(){
            loadjzt();
            postDownLoadFile({
                url:'/jxcsxm/shares/exportmb.do',
                data:null,
                method:'post'
            });
            loadShareJhxdwh("jhxdwh", "share_funds");
            //window.location.href='/jxcsxm/zjdw/dcmb.do';
            setTimeout('disLoadjzt()',4000);
        }

        // todo 导入模板
        function drsj(){
            var url="/jxcsxm/shares/importSharefundData.do?gydwdm="+$.cookie("unit");
            var flag='tzrczjdw';
            openWindow("导入数据","/jxcsxm/page/sjdr.jsp?url="+url+"&flag="+flag,500,300);
        }

        function queryXmlist() {
            var xzqhdm=$("#xzqh").combotree("getValues");
            if(xzqhdm.length==0){
                xzqhstr= $.cookie("dist2");
            }else if(xzqhdm.length==1){
                if(xzqhdm[0].substr(xzqhdm[0].length-2,xzqhdm[0].length)=="00") xzqhdm[0]=xzqhdm[0].substr(0,xzqhdm[0].length-2);
                if(xzqhdm[0].substr(xzqhdm[0].length-2,xzqhdm[0].length)=="00") xzqhdm[0]=xzqhdm[0].substr(0,xzqhdm[0].length-2);
                xzqhstr=xzqhdm[0] ;
            }else{
                xzqhstr= xzqhdm.join(',');
            }
            var xmnf=$("#xmnf").combobox("getValues").join(",");
            if(xmnf.substr(0,1)==',')
                xmnf=xmnf.substr(1,xmnf.length);
            var jhxdwh=$("#jhxdwh").combobox("getText");
            if(jhxdwh.substr(0,1)==',')
                jhxdwh=jhxdwh.substr(1,jhxdwh.length);

            var params = {
                'xzqh': xzqhstr,
                'gydw': 2,
                'xmnf': xmnf,
                'xmmc': $("#xmmc").val(),
                'jhxdwh': jhxdwh,
                'xmdj': '国省道',
                'sbthcd': $.cookie("unit2").length
            };

            loadTj();

            $('#grid').datagrid({
                url:'/jxcsxm/shares/queryJhXmlist.do',
                striped:true,
                pagination:true,
                rownumbers:true,
                pageNumber:1,
                pageSize:pageSize_,
                checkOnSelect:true,
                height:$(window).height()-190,
                width:$('#searchField').width()+2,
                queryParams: params,
                onSelectPage: function (pageNumber, pageSize) {
                    pageSize_ = pageSize;
                },
                onBeforeLoad: function () {
                    pageSize_ = $("#grid").datagrid("options").pageSize;
                },
                columns:[[	{field:'cz',title:'操作',width:130,align:'center',
                    formatter: function(value,row,index){
                        var result = "";
                        if ($.cookie('unit2').length==7) {
                            result ='<a style="color:#3399CC;" href="javascript:delSharefundData('+"'"+index+"'" + ')" >删除| </a>';
                        }
                         result +='<a style="color:#3399CC;" href="javascript:openXmInfo('+"'"+row.xmbm+"','gs_share_funds','jhcx'"+')" >项目详情</a>';
                        return result;
                    }
                },
                    {field:'xmnf',title:'项目年份',width:60,align:'center'},
                    {field:'xmmc',title:'项目名称',width:400,align:'center'},
                    {field:'xzqh',title:'行政区划',width:100,align:'center'},
                    {field:'jhxdwh',title:'计划下达文号',width:390,align:'center'},
                    // {field:'ztz',title:'总补助资金（万元）',width:100,align:'center'},
                    // title="放方便报表统计，此数值为省级下达至市级金额的50%，地市到位及拨付资金可在省级下达金额范围内填报。" alt="放方便报表统计，此数值为省级下达至市级金额的50%，地市到位及拨付资金可在省级下达金额范围内填报。"
                    {
                        field: 'ztz',
                        title: $.cookie('unit2').length==11 ? '总补助资金（万元）' : '<span>总补助资金（万元）</span><span id="span_tooltip" ' +
                            ' class="icon_mark" ' +
                            'title="为方便报表统计，此数值为省级下达至市级金额的50%，地市到位及拨付资金可在省级下达金额范围内填报。" ' +
                            'alt="为方便报表统计，此数值为省级下达至市级金额的50%，地市到位及拨付资金可在省级下达金额范围内填报。"></span>',
                        width: 140,
                        align: 'center'
                    },
                ]]
            });
        }

        function delSharefundData(index) {
            var row = $("#grid").datagrid("getRows")[index];
            if(confirm("您确认删除吗？")) {
                $.ajax({
                    type:'post',
                    url:'/jxcsxm/shares/delSharefundXm.do',
                    data:"xzqhdm="+row.xzqhdm+"&xmbm="+row.xmbm+"&jhxdwh="+row.jhxdwh + "&id="+row.id+"&xmnf="+row.xmnf,
                    dataType:'json',
                    success:function(data){
                        if(data.success){
                            alert(data.msg);
                            loadTj();
                            $("#grid").datagrid('reload');
                        }else{
                            alert("删除失败");
                        }

                    }
                });
            }
        }

        function loadTj(){
            var xzqhdm=$("#xzqh").combotree("getValues");
            if(xzqhdm.length==0){
                xzqhstr= $.cookie("dist2");
            }else if(xzqhdm.length==1){
                if(xzqhdm[0].substr(xzqhdm[0].length-2,xzqhdm[0].length)=="00") xzqhdm[0]=xzqhdm[0].substr(0,xzqhdm[0].length-2);
                if(xzqhdm[0].substr(xzqhdm[0].length-2,xzqhdm[0].length)=="00") xzqhdm[0]=xzqhdm[0].substr(0,xzqhdm[0].length-2);
                xzqhstr=xzqhdm[0] ;
            }else{
                xzqhstr= xzqhdm.join(',');
            }
            var xmnf=$("#xmnf").combobox("getValues").join(",");
            if(xmnf.substr(0,1)==',')
                xmnf=xmnf.substr(1,xmnf.length);

            var jhxdwh=$("#jhxdwh").combobox("getText");
            if(jhxdwh.substr(0,1)==',')
                jhxdwh=jhxdwh.substr(1,jhxdwh.length);

            var params = {
                'xzqh': xzqhstr,
                'gydw': 2,
                'xmnf': xmnf,
                'xmmc': $("#xmmc").val(),
                'jhxdwh': jhxdwh,
                'xmdj': '国省道',
                'sbthcd': $.cookie("unit2").length
            };

            $.ajax({
                type:'post',
                url:'/jxcsxm/shares/getJhTjAll.do',
                data:params,
                dataType:'json',
                success:function(msg){
                    $("#xmsl").html(msg.xmsl);
                    $("#xdzbz").html(msg.xdzbz);$("#xdbb").html(msg.xdbb);$("#xdsb").html(msg.xdsb);$("#xddf").html(msg.xddf);
                    $("#dwzbz").html(msg.dwzbz);$("#dwbb").html(msg.dwbb);$("#dwsb").html(msg.dwsb);$("#dwdf").html(msg.dwdf);
                    $("#bfzbz").html(msg.bfzbz);$("#bfbb").html(msg.bfbb);$("#bfsb").html(msg.bfsb);$("#bfdf").html(msg.bfdf);
                }
            });
        }
    </script>
    <style type="text/css">
        TD {
            font-size: 12px;
        }
        a{
            text-decoration:none;
        }
        .abgc_td td{padding-right:5px;}
    </style>
</head>
<body>
    <div id="righttop">
        <div id="p_top">计划查询>&nbsp;普通国省道>&nbsp;分成资金</div>
    </div>
    <table width="99.9%" border="0" style="margin-top: 1px; margin-left: 1px;"
           cellspacing="0" cellpadding="0">
        <tr>
            <td align="left" style="padding-left:10px;padding-right: 10px; padding-top: 5px;">
                <fieldset id="searchField" style="width:99.9%; text-align: left; vertical-align: middle;">
                    <legend style="padding: 0 0 0 0; font-weight: bold; color: Gray; font-size: 12px;">
                        <font style="color: #0866A0; font-weight: bold"></font>
                    </legend>
                    <div>
                        <table style="margin:4px; vertical-align:middle;" cellspacing="0" class="abgc_td" >
                            <tr height="28">
                                <td align="right">行政区划：</td>
                                <td><select id="xzqh" style="width:165px;"></select></td>
                                <td align="right">项目年份：</td>
                                <td><select id="xmnf" style="width: 80px;"></select></td>
                                <td align="right">项目名称：</td>
                                <td><input name="xmmc" type="text" id="xmmc" style="width:140px;" /></td>
                                <td align="right">计划下达文号：</td>
                                <td><input name="jhxdwh" type="text" id="jhxdwh" style="width:165px;" /></td>
                            </tr>
                            <tr height="28">
                                <td colspan="8">
                                    <a id='mybuttion1' style="margin-top: 1px;margin-bottom: 1px;" title="请按照导出模板格式导入数据" alt="请按照导出模板格式导入数据" href="javascript:queryXmlist()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">查询</a>
                                    <a name='tianjia' id='mybuttion2' style="margin-left: 5px;margin-bottom: 1px;" href="javascript:zjdwtj()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion1')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion1')"  class="button button-tiny button-rounded button-raised button-primary">添加</a>
                                    <a name='xian' id='mybuttion3' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:dcmb()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion3')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion3')"  class="button button-tiny button-rounded button-raised button-primary">导出模版</a>
                                    <a name='xian' id='mybuttion4' style="margin-top: 1px;margin-bottom: 1px;" href="javascript:drsj()" onmouseover="szgq('button button-tiny button-glow button-rounded button-raised button-primary','mybuttion4')" onmouseout="szgq('button button-tiny button-rounded button-raised button-primary','mybuttion4')"  class="button button-tiny button-rounded button-raised button-primary">导入数据</a>
                                </td>
                            </tr>
                        </table>
                    </div>
                </fieldset>
            </td>
        </tr>
        <tr>
            <td style="padding-left: 10px; font-size:12px;">
                <table>
                    <tr>
                        <td colspan="2">共有项目【<span id="xmsl" style="color: red;font-weight: bold;">0</span>】个。</td>
                    </tr>
                    <tr>
                        <td>下达补助【<span id="xdzbz" style="color: Red; font-weight: bold;">0</span>】万元（部补【<span id="xdbb" style="color: Red; font-weight: bold;">0</span>】万元，省补【<span id="xdsb" style="color: Red; font-weight: bold;">0</span>】万元），地方自筹【<span id="xddf" style="color: Red; font-weight: bold;">0</span>】万元。</td>
                        <td style="padding-left: 10px;">到位补助【<span id="dwzbz" style="color: Red; font-weight: bold;">0</span>】万元（部补【<span id="dwbb" style="color: Red; font-weight: bold;">0</span>】万元，省补【<span id="dwsb" style="color: Red; font-weight: bold;">0</span>】万元），地方自筹【<span id="dwdf" style="color: Red; font-weight: bold;">0</span>】万元。</td>
                    </tr>
                    <tr>
                        <td>拨付补助【<span id="bfzbz" style="color: Red; font-weight: bold;">0</span>】万元（部补【<span id="bfbb" style="color: Red; font-weight: bold;">0</span>】万元，省补【<span id="bfsb" style="color: Red; font-weight: bold;">0</span>】万元），地方自筹【<span id="bfdf" style="color: Red; font-weight: bold;">0</span>】万元。</td>
                    </tr>
                </table>
                <div><table id="grid"></table></div>
            </td>
        </tr>
    </table>
</body>
</html>